import game.ai.models
from game.combat.combatActionRequest import combatActionRequest
from game.common.logger import logger

def getActionRequest(sender, **kwargs):
    combatant = kwargs['combatant']
    logger.debug("Signal Received: %s is ready to act. Using %s as the controller" % (combatant.individual.name, combatant.get_controller_display()) )
    if combatant.controller != 0:
    	#Load and instantiate the controller class for the combatant
    	controller = getattr(game.ai.models, combatant.get_controller_display())
    	controller = controller(sender, combatant)
        request = combatActionRequest(controller.getAction(), combatant, controller.getTarget(), combatant.currentCombat)
        combatant.currentCombat.processRequest(request)
    else:
        #Do nothing, it is a player controlled monster.
    	pass